﻿using System.Runtime.Serialization;

namespace Order
{
    [DataContract]
    public class Address : System.ICloneable
    {
        [DataMember]
        [System.ComponentModel.DataAnnotations.Key]
        public int ID { get; init; }
        [DataMember]
        public string Location { get; set; }
        public Address()
        {
            ID = base.GetHashCode();
        }
        public override string ToString()
        {
            return "Address: " + Location;
        }
        public override bool Equals(object obj)
        {
            if (obj is not Address add) return false;
            return Location == add.Location;
        }

        public override int GetHashCode()
        {
            return Location?.GetHashCode() ?? 0;
        }

        public object Clone()
        {
            return new Address()
            {
                ID = ID,
                Location = Location
            };
        }
    }
}
